/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.meserovirtual.modelos;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Adalberto
 */
@Entity
@Table(name = "mesa")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Mesa.findAll", query = "SELECT m FROM Mesa m"),
    @NamedQuery(name = "Mesa.findByCodigo", query = "SELECT m FROM Mesa m WHERE m.codigo = :codigo"),
    @NamedQuery(name = "Mesa.findByDescripcion", query = "SELECT m FROM Mesa m WHERE m.descripcion = :descripcion"),
    @NamedQuery(name = "Mesa.findByEliminado", query = "SELECT m FROM Mesa m WHERE m.eliminado = :eliminado")})
public class Mesa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "codigo")
    private Integer codigo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "descripcion")
    private String descripcion;
    @Basic(optional = false)
    @NotNull
    @Column(name = "eliminado")
    private boolean eliminado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "mesa")
    private List<PedidoCliente> pedidoClienteList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "mesa")
    private List<PedidoClienteRegistrado> pedidoClienteRegistradoList;

    public Mesa() {
    }

    public Mesa(Integer codigo) {
        this.codigo = codigo;
    }

    public Mesa(Integer codigo, String descripcion, boolean eliminado) {
        this.codigo = codigo;
        this.descripcion = descripcion;
        this.eliminado = eliminado;
    }

    public Integer getCodigo() {
        return codigo;
    }

    public void setCodigo(Integer codigo) {
        this.codigo = codigo;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public boolean getEliminado() {
        return eliminado;
    }

    public void setEliminado(boolean eliminado) {
        this.eliminado = eliminado;
    }

    @XmlTransient
    public List<PedidoCliente> getPedidoClienteList() {
        return pedidoClienteList;
    }

    public void setPedidoClienteList(List<PedidoCliente> pedidoClienteList) {
        this.pedidoClienteList = pedidoClienteList;
    }

    @XmlTransient
    public List<PedidoClienteRegistrado> getPedidoClienteRegistradoList() {
        return pedidoClienteRegistradoList;
    }

    public void setPedidoClienteRegistradoList(List<PedidoClienteRegistrado> pedidoClienteRegistradoList) {
        this.pedidoClienteRegistradoList = pedidoClienteRegistradoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codigo != null ? codigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Mesa)) {
            return false;
        }
        Mesa other = (Mesa) object;
        if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.meserovirtual.modelos.Mesa[ codigo=" + codigo + " ]";
    }
    
}
